class Solution:
    def longestMountain(self, A: List[int]) -> int:
        order=0
        result=0
        count=0
        start=0
        while start<len(A)-1 and A[start]>=A[start+1]:
            start=start+1
        for i in range(start,len(A)-1):
            if A[i]<A[i+1]:
                if order==1:
                    count+=1
                elif order==-1:
                    if result<count+1:
                        result=count+1
                    order=1
                    count=1
                else:
                    order=1
                    count=1
            elif A[i]==A[i+1]:
                if order==-1:
                    if result<count+1:
                        result=count+1
                    while i<len(A)-1 and A[i]>=A[i+1]:
                        i=i+1
                order=0  
                count=0
            else:
                if order==1:
                    order=-1
                    count+=1
                elif order==0:
                    count=0
                else:
                    count+=1
        if order==-1 and result<count+1:
            result=count+1
        return result